<?php
/**
 * Created by PhpStorm.
 * User: 97606
 * Date: 2019/2/26
 * Time: 10:23
 */

namespace App\Http\Controllers\NewAdmin;

use App\Http\Controllers\AdapterWebController;
use App\Modules\UCenter\Car as ApiCar;
use Illuminate\Http\Request;

class Car extends AdapterWebController
{
    // 车辆列表
    public function index(Request $request)
    {
        if (empty($request['keywords'])) {
            $postData['keywords'] = '';
        } else {
            $postData['keywords'] = $request['keywords'];
        }
        $cars = $this->appLayerExec(ApiCar::class, 'backCarList', $postData);
        return view('newAdmin.car.index', ['cars' => $cars['res']]);
    }

    // 车辆信息
    public function info($id)
    {
        $postData['id'] = $id;
        $info = $this->appLayerExec(ApiCar::class, 'backCarInfo', $postData);
        return view('newAdmin.car.info', ['info' => $info['res']]);
    }

    // 车辆审核
    public function audit()
    {
        $res = $this->appLayerExec(ApiCar::class, 'backCarAudit', request()->all());
        if ($res['code'] == 200) {
            return ['status' => 0, 'msg' => '审核已完成!'];
        }
        return ['status' => -1, 'msg' => '审核失败，请重试!'];
    }
}
